﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FileHelpers;
using System.Configuration;
using Nebular.ExpenseManagement.Connector.Toolbox;
using System.Reflection; //TODO : Refactor to external class

namespace Nebular.ExpenseManagement.Connector.EuroCard
{
    class Program
    {
        static void Main(string[] args)
        {


            Console.WriteLine("Starting transfer");
            //TODO : Transform from File


            FileHelperEngine<EurocardFileImport> engine = new FileHelperEngine<EurocardFileImport>();

            EurocardFileImport[] res = engine.ReadFile(ConfigurationSettings.AppSettings["FileLocation"]);

            
            foreach (EurocardFileImport record in res)
            {
                // Your Code Here

                //TODO : Refactor to external Class

                FieldInfo[] infos = record.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
                foreach (var fi in infos)
                {
                    
                    Console.WriteLine(fi.Name + " : " + fi.GetValue(record).ToString()  );

                    // fi.GetCustomAttributes(typeof(MapToAttribute))[0]).GetValue()

                    //TODO : Transform to Common Object. (DemoTransactionPayoadClass.cs)
                }
                Console.ReadKey();

            }

            

            //TODO : Send to ExpenseManagement.

            //TODO : Logging,

            //TODO : Error Handling

        }
    }
}
